package com.snopy.collection.set.treeset;

import lombok.extern.slf4j.Slf4j;

import java.util.SortedSet;
import java.util.TreeSet;

/**
 * @author snopy
 * @version 1.0.0
 * @classname DemoTreeSET
 * @description
 * @email 77912204@qq.com
 * @date 2022/07/28 16:48
 */
@Slf4j
public class DemoTreeSet {

    public static void main(String[] args) {
        TreeSet<String> ts = new TreeSet<>();
        ts.add("a");
        ts.add("b");
        ts.add("c");
        ts.add("d");
        ts.add("e");
        ts.add("f");
        log.info("size: {}",ts.size());
        log.info("isEmpty: {}",ts.pollFirst());
        log.info("size: {}",ts.size());
        SortedSet<String> a = ts.headSet("f");
        //ts.tailSet("g");
        String first = a.first();
        log.info(a.toString());
        SortedSet<String> d = ts.tailSet("d");
        log.info("d: {}",d);
        ts.parallelStream().filter(s -> s.contains("a")).forEach(System.out::println);
        //IMMUTABLE


    }
}
